/**
 * Created by dingjie5 on 2015/12/22.
 */
$(function(){
    $("a[name='linkproject']").bind("click",function(){
        var url = this.attributes["codeurl"].nodeValue;
        $.ajax({
            url: "/initWhiteUser.action",
            type: "post",
            dataType: "json",
            scriptCharset: "utf-8",
            success: function (data) {
                if(data.isSuccess){
                    var linkUrl =url+"&rcode="+data.code;
                    //window.open(linkUrl);
                    referURL(linkUrl);
                }else{
                    alert("项目暂时不可预览");
                }
            }
        });
    });
    $("a[name='linkreport']").bind("click",function(){
        var url = this.attributes["codeurl"].nodeValue;
        $.ajax({
            url: "/initWhiteUser.action",
            type: "post",
            dataType: "json",
            scriptCharset: "utf-8",
            success: function (data) {
                if(data.isSuccess){
                    var linkUrl =url+"?rcode="+data.code;
                   // window.open(linkUrl)
                    referURL(linkUrl);
                }else{
                    alert("报告暂时不可预览");
                }
            }
        });
    });
});
function referURL(url){
    var navigatorName = "Microsoft Internet Explorer";
    if( navigator.appName == navigatorName ){
        var linka = document.createElement('a');
        linka.setAttribute("target","_bank");
        linka.href=url;
        document.body.appendChild(linka);
        linka.click();
    }
    else {
        window.open(url);
    }
}
